/**
 * @author ChaP
 * @date 2019/04/23
 * @describe:
 */
package CodingTest.AC20190423;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

/**
 * leetcode -17
 * 电话号码的字母组合
 */
public class letterCombinations {
    public List<String> letterCombinations(String digits){
        if(digits.length() == 0) return new ArrayList<>();
        HashMap<Character,String> hs = new HashMap<Character, String>();
        hs.put('2',"abc");
        hs.put('3',"def");
        hs.put('4',"ghi");
        hs.put('5',"jkl");
        hs.put('6',"mno");
        hs.put('7',"pqrs");
        hs.put('8',"tuv");
        hs.put('9',"wxyz");

        String s1 = hs.get(digits.charAt(0));
        String s2 = hs.get(digits.charAt(1));
        List<String> res= new ArrayList<>();
        for(int i = 0;i<s1.length();i++){
            for(int j =0;j<s2.length();j++){
                String s = s1.charAt(i)+""+s2.charAt(j);
                res.add(s);
            }

        }
        return res;
    }

    public static void main(String[] args) {
        letterCombinations lc = new letterCombinations();
        System.out.println(lc.letterCombinations("23"));
    }

}
